File I-O Functions and Statements Creating a new file or accessing an existing file or device ----------------------------------------------------------- OPEN Opens a file or device for retrieving or storing records (I-O). Closing a file or device ------------------------ CLOSE Ends I-O to a file or device. Storing data in a file ---------------------- PRINT # Stores a list of variables as record fields in a previously opened file.1 PRINT # USING Similar to PRINT #, except PRINT # USING formats the record fields.1 WRITE # Stores a list of variables as record fields in a previously opened file.1 WIDTH # Specifies a standard width for each record in a file.1 PUT Stores the contents of a user-defined variable in a previously opened file.2 Retrieving data from a file --------------------------- INPUT # Reads fields from a record and assigns each field in the record to a program variable.1 INPUT$ Reads a string of characters from a file. LINE INPUT # Reads a record and stores it in a single string variable.1 GET Reads data from a file and assigns the data to elements of a user-defined variable.2 Getting information about a file -------------------------------- EOF Tests whether all data has been read from a file. FILEATTR Returns the number assigned by the operating system to an open file and a number that indicates the mode in which the file was opened (input, output, append, binary, random, or ISAM). LOC Gives the current position within a file. With binary access, this is the byte position. With sequential access, this is the byte position divided by 128. With random access, this is the record number of the last record read or written. LOF Gives number of bytes in open file. SEEK Function Gives the location where the next I-O operation will take place. With random access, this is the number of the next record to be read or written. With all other kinds of file access, this is the byte position of the next byte to be read or written. Moving around in a file ----------------------- SEEK Statement Sets the byte position or record number for the next read or write operation in an open file. Managing disk drives, directories, and files -------------------------------------------- CHDRIVE Changes the current drive. CURDIR$ Gives current directory specifica-tion for specified drive (or current drive if no drive is specified). DIR$ On first call, returns the first file that matches the file specification. On successive calls (with no argument), returns remaining files matching the file specification. FILES Prints a listing of the files in a specified directory. FREEFILE Returns next available file number. KILL Deletes a file from the disk. NAME Changes a file's name. 1 For use with sequential files. 2 For use with binary or random-access files.